﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>案件管理</title>
    <link rel="stylesheet" type="text/css" href="../../easyui/1.3.4/themes/metro/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/yz-global.css" />
    <link rel="stylesheet" type="text/css" href="../../css/yz-icon.css" />
</head>

<body>
    <div class="easyui-layout" data-options="fit:true">
        <!-- Begin of toolbar -->
        <div id="yz-toolbar-2">
            <div class="yz-toolbar-button">
                <a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="openAdd()" plain="true">添加</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-edit" onclick="openEdit()" plain="true">修改</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="remove()" plain="true">删除</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-sum" onclick="reload()" plain="true">统计</a>
            </div>
            <div class="yz-toolbar-search">
                <label>起始时间：</label>
                <input class="easyui-datebox" style="width:100px">
                <label>结束时间：</label>
                <input class="easyui-datebox" style="width:100px">
                <label>关键词：</label>
                <input class="yz-text" style="width:100px">
                <a href="#" class="easyui-linkbutton" iconCls="icon-search">开始检索</a>
            </div>
        </div>

        <table id="yz-datagrid-2" class="easyui-datagrid" toolbar="#yz-toolbar-2"></table>
    </div>

    <div id="yz-dialog-editCase" class="easyui-window" data-options="closed:true,iconCls:'icon-save'" style="width:800px;height:700px;  padding:10px;">
        <iframe scrolling="auto" id='editCaseIframe' frameborder="0"  src="editCase.html" style="width:100%;height:100%;"></iframe>
    </div>
    <div id="yz-dialog-viewCase" class="easyui-dialog" data-options="closed:true,iconCls:'icon-save'" style="width:400px; padding:10px;">
        <iframe scrolling="auto" id='viewCaseIframe' frameborder="0"  src="viewCase.html" style="width:100%;height:100%;"></iframe>
    </div>
    <script type="text/javascript" src="../../js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../../easyui/1.3.4/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
    /**
     * Name 添加记录
     */
    function add() {
        $('#yz-form-2').form('submit', {
            url: '',
            success: function(data) {
                if (data) {
                    $.messager.alert('信息提示', '提交成功！', 'info');
                    $('#yz-dialog-editCase').dialog('close');
                } else {
                    $.messager.alert('信息提示', '提交失败！', 'info');
                }
            }
        });
    }

    /**
     * Name 修改记录
     */
    function edit() {
        $('#yz-form-2').form('submit', {
            url: '',
            success: function(data) {
                if (data) {
                    $.messager.alert('信息提示', '提交成功！', 'info');
                    $('#yz-dialog-editCase').dialog('close');
                } else {
                    $.messager.alert('信息提示', '提交失败！', 'info');
                }
            }
        });
    }

    /**
     * Name 删除记录
     */
    function remove() {
        $.messager.confirm('信息提示', '确定要删除该记录？', function(result) {
            if (result) {
                var items = $('#yz-datagrid-2').datagrid('getSelections');
                var ids = [];
                $(items).each(function() {
                    ids.push(this.productid);
                });
                //alert(ids);return;
                $.ajax({
                    url: '',
                    data: '',
                    success: function(data) {
                        if (data) {
                            $.messager.alert('信息提示', '删除成功！', 'info');
                        } else {
                            $.messager.alert('信息提示', '删除失败！', 'info');
                        }
                    }
                });
            }
        });
    }

    /**
     * Name 打开添加窗口
     */
    function openAdd() {
        $('#yz-form-2').form('clear');
        $('#yz-dialog-editCase').window({
            closed: false,
            resizable:false,
            modal: true,
            constrain:true,
            draggable:false,
            inline:true,
            title: "添加案件"
        });

    }

    /**
     * Name 打开修改窗口
     */
    function openEdit() {
        $('#yz-form-2').form('clear');
        var item = $('#yz-datagrid-2').datagrid('getSelected');
        //alert(item.productid);return;
        $.ajax({
            url: '',
            data: '',
            success: function(data) {
                if (data) {
                    $('#yz-dialog-editCase').dialog('close');
                } else {
                    //绑定值
                    $('#yz-form-2').form('load', data)
                }
            }
        });
        $('#yz-dialog-editCase').dialog({
            closed: false,
            modal: true,
            title: "修改信息",
            buttons: [{
                text: '确定',
                iconCls: 'icon-ok',
                handler: edit
            }, {
                text: '取消',
                iconCls: 'icon-cancel',
                handler: function() {
                    $('#yz-dialog-editCase').dialog('close');
                }
            }]
        });
    }

    /**
     * Name 分页过滤器
     */
    function pagerFilter(data) {
        if (typeof data.length == 'number' && typeof data.splice == 'function') { // is array                
            data = {
                total: data.length,
                rows: data
            }
        }
        var dg = $(this);
        var opts = dg.datagrid('options');
        var pager = dg.datagrid('getPager');
        pager.pagination({
            onSelectPage: function(pageNum, pageSize) {
                opts.pageNumber = pageNum;
                opts.pageSize = pageSize;
                pager.pagination('refresh', {
                    pageNumber: pageNum,
                    pageSize: pageSize
                });
                dg.datagrid('loadData', data);
            }
        });
        if (!data.originalRows) {
            data.originalRows = (data.rows);
        }
        var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
        var end = start + parseInt(opts.pageSize);
        data.rows = (data.originalRows.slice(start, end));
        return data;
    }

    /**
     * Name 载入数据
     */
    $('#yz-datagrid-2').datagrid({
        url: '../../temp/datagrid.php',
        loadFilter: pagerFilter,
        rownumbers: true,
        singleSelect: false,
        pageSize: 20,
        pagination: true,
        multiSort: true,
        fitColumns: true,
        fit: true,
        columns:[[
            { checkbox:true},
            { field:'productid',title:'productid',width:100,sortable:true},
            { field:'productname',title:'productname',width:180,sortable:true},
            { field:'unitcost',title:'unitcost',width:100},
            { field:'listprice',title:'listprice',width:100},
            { field:'attr1',title:'attr1',width:100},
            { field:'itemid',title:'itemid',width:100},
            { field:'status',title:'status',width:100}
        ]]
    });
    </script>
</body>

</html>
